<template>
  <el-dialog
    :title="title"
    :visible.sync="dialog.isShow"
    :width="width"
    :top="top"
    :close-on-click-modal="false"
    @close="closeEvent"
  >
    <div :style="{height:height}">
      <iframe ref="iframe" :src="url" class="iframe" />
    </div>

  </el-dialog>
</template>

<script>
export default {
  name: 'DialogIframe',
  components: {},
  props: {
    urlPath: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: '流程图'
    }

  },
  data() {
    return {
      dialog: {
        isShow: false
      },
      width: '800px',
      height: '400px',
      top: '70px'
    }
  },
  computed: {
    url() {
      return this.urlPath
    }
  },
  created() {
    this.fullscreenLoading = true
  },
  mounted() {
    // this.iframeInit()
    // window.onresize = () => {
    //   this.iframeInit()
    // }
  },
  methods: {
    show() {
      this.dialog.isShow = true
    },
    closeEvent() {
      this.$emit('close')
    },
    iframeInit() {
      const iframe = this.$refs.iframe
      const clientHeight = document.documentElement.clientHeight - 90
      iframe.style.height = `${clientHeight}px`
      if (iframe.attachEvent) {
        iframe.attachEvent('onload', () => {
          this.fullscreenLoading = false
        })
      } else {
        iframe.onload = () => {
          this.fullscreenLoading = false
        }
      }
    }
  }
}
</script>
<style  scoped>
.wp{
    height:400px;
}
</style>

<style>
.iframe {
  width: 100%;
  height: 100%;
  border: 0;
  overflow: hidden;
  box-sizing: border-box;
}
</style>
